package com.ruoyi.third.base;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class InvoiceApiResult<T> implements Serializable {

    private Integer code;

    private String msg;

    private T data;

    private Integer total;

    public static InvoiceApiResult success(Object data) {
        return new InvoiceApiResult(200, "成功", data, data instanceof List ? ((List<?>) data).size() : 0);
    }

    public static InvoiceApiResult fail(String msg) {
        return new InvoiceApiResult(500, msg, null, null);
    }

}
